 package com.system.demo.controller.mainPage;

import cn.dev33.satoken.annotation.SaCheckRole;
import com.system.demo.entity.mailPage.CarouselDTO;
import com.system.demo.service.MainPage.MailPageService;
import com.system.demo.tool.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/home/admin")
@SaCheckRole("ROLE_ADMIN")
public class mainPageAdminController {

    @Autowired
    private MailPageService mailPageService;
    @GetMapping("/getData")
    public ResponseResult<?> getDataByAdmin(){
        return mailPageService.getDataByAdmin();
    }

    @GetMapping("/getWork")
    public ResponseResult<?> getWork(){
        return mailPageService.getWork();
    }

    //添加轮播图
    @PostMapping("/addCarousel")
    public ResponseResult<?> addCarousel(@ModelAttribute CarouselDTO carouselDTO){
        return mailPageService.addCarousel(carouselDTO);
    }

    @GetMapping
    public ResponseResult<?> getCarousels(){
        return mailPageService.getCarousels();
    }

    @DeleteMapping
    public ResponseResult<?> deleteCarousel(@RequestParam Integer carouselId){
        return mailPageService.deleteCarousel(carouselId);
    }
}
